<template>
	<view>
		<view class="my-user">
			<!-- 头像 -->
			<view class="nav-bg">
				<view class="content">
					<view class="head-image">
						<image :src="userList.headimgurl" v-if="!isAuthShow" style="width: 100%;height: 100%;border-radius:50%;"></image>
						<image src="../../static/logo.jpg" v-if="isAuthShow" style="width: 100%;height: 100%;border-radius:50%;"></image>
					</view>
				</view>
					<view class="head-text">
						<text class="text" v-show="!isAuthShow">{{userList.nickname}}</text>
						<!-- <open-data type="userNickName" v-show="isAuthShow" class="text" ></open-data> -->
					</view>
			</view>
			<!-- 列表 -->
			<view class="my-cell">
				<!-- <u-cell-item icon="file-text-fill" title="订单列表" @click = "toPage('pages/order/order_list')"></u-cell-item> -->
				<!-- <u-cell-item icon="man-add-fill" title="申请注册" @click="regsiter"></u-cell-item> -->
				
				<u-cell-item icon="calendar-fill" v-if="userList.is_share == 1" title="推广中心" @click="toPage('pages/user/promotion_center')"></u-cell-item>
			</view>
<!-- 			<u-cell-group class="action">
				<button type="default" class='contact-btn '>
					<u-cell-item icon="order" title="我的订单"></u-cell-item>
				</button>
				<button type="default" @click="callPhone()" class='contact-btn '>
					<u-cell-item icon="phone"  title="客服电话"></u-cell-item>
				</button>
				<button type="default" open-type='contact' class='contact-btn '>
					<u-cell-item icon="server-man" title="客服电话"></u-cell-item>
				</button>
			</u-cell-group> -->
			<!-- 卡片 -->
			<view style="display: flex;justify-content: space-between;margin: 10px;">
				<button type="default" @click="callPhone()" class="card">
					<u-icon name="phone" color="#3e3e3e" :size="50"></u-icon>
					<view style="width: 100%; margin-top: 10px;font-size: 13px;">
						客服电话
					</view>
				</button>
				<button type="default" open-type='contact' class="card">
					<u-icon name="server-man" color="#3e3e3e" :size="50"></u-icon>
					<view style="width: 100%; margin-top: 10px;font-size: 13px;">
						联系客服
					</view>
				</button>
			</view>
		</view>
		<u-popup v-model="popupShow" mode="right" length="100%">
			<view class="pop-clss">
				<view class="submit-icon">
					<u-icon :name="msg(userList.status).name" :color="msg(userList.status).color" size="200">
					</u-icon>
				</view>
				<view class="submit-text">
					<view>{{msg(userList.status).text}}</view>
				</view>
				<view class="submit-btn">
					<u-button size="medium" :ripple="true" ripple-bg-color="#58c06b" @click="close">完 成</u-button>
				</view>
			</view>
		</u-popup>
		<u-toast ref="uToast" />
		<authDialog :isAuthShow="isAuthShow" @authConfirm="authConfirm"></authDialog>
	</view>
</template>
<script>
	export default {
		onShow() {
			this.isAuthShow = false
			if (this.$u.test.isEmpty(this.vuex_token)) {
				this.isAuthShow = true
			}
			this.getuserinfo()
		},
		onLoad() {
		},
		data() {
			return {
				userList: [],
				isAuthShow: false,
				popupShow: false,
			}
		},
		methods: {
			// 授权
			authConfirm() {
				this.getuserinfo()
				this.isAuthShow = false;
			},
			regsiter() {
				if (this.userList.status != 2) {
					this.popupShow = true
					return
				}
				this.$u.route({
					type: 'navigateTo',
					url: 'pages/user/login',
				})
			},
			close() {
				this.popupShow = false
			},
			callPhone(){
				let that = this;
				let postData = {
					"scenic_id": '1038'
				};
				that.$u.post('/api/ticket/list', postData).then(res => {
					uni.makePhoneCall({
						phoneNumber: res.scenic.kf
					})
				});
			},
			toPage(path) {
				this.$u.route({
					url: path
				});
			},
			getuserinfo() {
				let that = this;
				that.$u.post('/api/user/user_info').then(res => {
					console.log(res, "shuju ")
					that.userList = res
				});
			},
			msg(e) {
				switch (e) {
					case -1:
						return {
							text: "您已提交成功",
								color: "#58c06b",
								name: "checkmark-circle-fill"
						};
					case 1:
						return {
							text: "您已通过审核",
								color: "#58c06b",
								name: "checkmark-circle-fill"
						};
					case 3:
						return {
							text: "待审核注册信息",
								color: "#fbc531",
								name: "checkmark-circle-fill"
						};
					case 4:
						return {
							text: "审核信息失败",
								color: "#e74c3c",
								name: "close-circle-fill"
						};

					default:
						break;
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		align-items: center;
		width: 45% !important;
		border-radius: 10px;
		padding: 10px;
		view {
			text-align: center;
		}
	}
	// 联系客服
	button{
		position: relative;
		display: block;
		margin-left: auto;
		margin-right: auto;
		padding-left: 0px;
		padding-right: 0px;
		box-sizing: border-box;
		// font-size: 18px;
		text-align: center;
		text-decoration: none;
		// line-height: 1;
		line-height: 1.35;
		// border-radius: 5px;
		-webkit-tap-highlight-color: transparent;
		overflow: hidden;
		color: #000000;
		background-color: #FFFFFF;
		width: 100%;
		&::after {
			border: none;
			background-color: rgba(0,0,0, 0);
		}
	}
	.my-user {
		.nav-bg {
			width: 100%;
			height: 200rpx;
			background-color: #efb43e;
			display: flex;
			.content {
				border-radius: 50%;
				width: 150rpx;
				height: 150rpx;
				overflow: hidden;
				margin: 0 20rpx;
				.head-image {
					width: 150rpx;
					height: 150rpx;
					.avatar {
						width: 150rpx;
						height: 150rpx;
					}
				}
			}
			
			.head-text {
				margin: 10rpx 0;
				.text {
					color: #FFFFFF;
					font-size: 40rpx;
					padding: 20rpx 10rpx;
					font-weight: 500;
				}
			}
		}

		.my-cell {
			background-color: #FFFFFF;
		}

	}


	.submit-icon {
		margin-top: 150rpx;
		width: 100%;
		text-align: center;

	}

	.submit-text {
		padding: 30rpx;
		font-weight: 600;
		text-align: center;
		font-size: 35rpx;
		color: #626262;
	}

	.submit-btn {
		padding: 30rpx;
		text-align: center;
	}
</style>
